{% extends 'base.html' %}
{% load staticfiles %}
{% block title %}
    公开课详情 - 谷粒教育网
{% endblock %}
{% block content %}
    <section>
        <div class="wp">
            <div class="crumbs">
                <ul>
                    <li><a href="/">首页</a>></li>
                    <li><a href="{% url 'courses:course_list' %}">公开课程</a>></li>
                    <li>课程详情</li>
                </ul>
            </div>
        </div>
    </section>

    <section>
        <div class="wp">
            <div class="groupPurchase_detail detail">
                <div class="toppro">
                    <div class="left">
                        <div class="picbox">
                            <div class="tb-booth tb-pic">
                                <img width="440" height="445" src="{{ MEDIA_URL }}{{ course.image }}"
                                     class="jqzoom"/>
                            </div>

                        </div>
                        <div class="des">
                            <h1 title="{{ course.name }}">{{ course.name }}</h1>
                            <span class="key">{{ course.desc }}</span>
                            <div class="prize">
                                <span class="fl">难度：<i class="key">{{ course.get_level_display }}</i></span>
                                <span class="fr">学习人数：12</span>
                            </div>
                            <ul class="parameter">
                                <li><span
                                        class="pram word3">时&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;长：</span><span>{{ course.study_time }}</span>
                                </li>
                                <li><span
                                        class="pram word3">章&nbsp;节&nbsp;数：</span><span>{{ course.lessoninfo_set.count }}</span>
                                </li>
                                <li><span class="pram word3">课程类别：</span><span
                                        title="">{{ course.get_category_display }}</span></li>
                                <li class="piclist"><span class="pram word4">学习用户：</span>
                                    {% for user_course in course.usercourse_set.all|slice:':6' %}
                                        <span class="pic">
                                            <img width="40" height="40"
                                                 src="{{ MEDIA_URL }}{{ user_course.study_man.image }}"/>
                                        </span>
                                    {% endfor %}
                                </li>
                            </ul>
                            <div class="btns">
                                <div class="btn colectgroupbtn" id="jsLeftBtn">
                                    {% if love_course_flag %}
                                        取消收藏
                                    {% else %}
                                        收藏
                                    {% endif %}
                                </div>
                                <div class="buy btn"><a style="color: white"
                                                        href="{% url 'courses:course_video' course.id %}">开始学习</a></div>
                            </div>
                        </div>
                    </div>
                    <div class="right">
                        <div class="head">
                            <h1>授课机构</h1>
                            <p>世界名校，课程权威</p>
                        </div>
                        <div class="pic">
                            <a href="{% url 'orgs:org_detail' course.orgInfo.id %}">
                                <img width="150" height="80" src="{{ MEDIA_URL }}{{ course.orgInfo.image }}"/>
                            </a>
                        </div>
                        <a href="{% url 'orgs:org_detail' course.orgInfo.id %}">
                            <h2 class="center" title="{{ course.orgInfo.name }}">{{ course.orgInfo.name }}</h2>
                        </a>
                        <div class="btn  notlogin
					     " data-favid="14" id="jsRightBtn">
                            {% if love_org_flag %}
                                取消收藏
                            {% else %}
                                收藏
                            {% endif %}
                        </div>
                        <div class="clear">
                            <ul>
                                <li>
                                    <span>课 &nbsp;程&nbsp; 数：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {{ course.orgInfo.course_num }}</span>
                                </li>
                                <li>
                                    <span>教 &nbsp;师&nbsp; 数：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {{ course.orgInfo.teacherinfo_set.count }}</span>
                                </li>
                                <li>所在地区：&nbsp;&nbsp;{{ course.orgInfo.cityInfo.name }}</li>
                                <li>认&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;证&nbsp;:
                                    &nbsp;&nbsp;
                                    <img title="金牌机构" src="{% static 'images/gold.png' %}"/>
                                </li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <section>
        <div class="wp">
            <div class="list groupPurchase_detail_pro">
                <div class="left layout">
                    <div class="head">
                        <ul class="tab_header">
                            <li class="active">课程详情</li>
                        </ul>
                    </div>
                    <div class="tab_cont tab_cont1">

                        <p>
                            {{ course.detail }}
                        </p>

                    </div>
                </div>
                <div class="right layout">
                    <div class="head">相关课程推荐</div>
                    <div class="group_recommend">
                        {% for relate in relation_courses %}
                            <dl>
                                <dt>
                                    <a target="_blank" href="{% url 'courses:course_detail' relate.id %}">
                                        <img width="240" height="220" class="scrollLoading"
                                             src="{{ MEDIA_URL }}{{ relate.image }}"/>
                                    </a>
                                </dt>
                                <dd>
                                    <a target="_blank" href="{% url 'courses:course_detail' relate.id %}">
                                        <h2> {{ relate.name }}</h2></a>
                                    <span class="fl">学习时长：<i class="key">{{ relate.study_time }}</i></span>
                                </dd>
                            </dl>
                        {% endfor %}
                    </div>
                </div>
            </div>
        </div>
    </section>
{% endblock %}

{% block myjs %}
    <script type="text/javascript">
        $(function () {
            $('#jsLeftBtn').click(function () {
                var love_id =
                {{course.id}}
                var love_type = 2
                $.ajax({
                    type: 'GET',
                    url: '{% url 'operations:user_love' %}',
                    data: {
                        love_id: love_id,
                        love_type: love_type
                    },
                    success: function (callback) {
                        if (callback.status == 'ok') {
                            $('#jsLeftBtn').text(callback.msg)
                        } else {
                            alert(callback.msg)
                        }
                    }
                })
            })
            $('#jsRightBtn').click(function () {
                var love_id =
                {{course.orgInfo.id}}
                var love_type = 1
                $.ajax({
                    type: 'GET',
                    url: '{% url 'operations:user_love' %}',
                    data: {
                        love_id: love_id,
                        love_type: love_type
                    },
                    success: function (callback) {
                        if (callback.status == 'ok') {
                            $('#jsRightBtn').text(callback.msg)
                        } else {
                            alert(callback.msg)
                        }
                    }
                })
            })
        })
    </script>
{% endblock %}